package com.geek.javase.ch06.test3;

/*
 *@author wangpeng
 *2025/10/14 22:52
 *@description TODO
 */
//新闻类：标题，内容，时间   三个属性。 有10条新闻，按照时间的降序排列
public class Newss {
    String title;
    String content;
    String time;
    public Newss(String title, String content, String time) {
        this.title = title;
        this.content = content;
        this.time = time;
    }
    public Newss() {
    }
    public static void main(String[] args) {
        Newss[] news = new Newss[10];
        news[0] = new Newss("标题1","内容1","2023-03-10");
        news[1] = new Newss("标题2","内容2","2025-03-19");
        news[2] = new Newss("标题3","内容3","2025-03-12");
        news[3] = new Newss("标题4","内容4","2025-04-13");
        news[4] = new Newss("标题5","内容5","2015-03-14");
        news[5] = new Newss("标题6","内容6","1025-09-15");
        news[6] = new Newss("标题7","内容7","2027-03-16");
        news[7] = new Newss("标题8","内容8","2025-09-17");
        news[8] = new Newss("标题9","内容9","2025-12-18");
        news[9] = new Newss("标题10","内容10","2025-03-19");
        for (int i = 0; i < news.length; i++) {
            for (int j = i+1; j < news.length; j++) {
                if (news[i].time.compareTo(news[j].time)>0) {
                    Newss temp = news[i];
                    news[i] = news[j];
                    news[j] = temp;
                }
            }
        }
        for (int i = 0; i < news.length; i++) {
            System.out.println(news[i].title+" "+news[i].content+" "+news[i].time);
        }
    }
}
